package com.bestow.basic.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.bestow.common.annotation.Log;
import com.bestow.common.core.controller.BaseController;
import com.bestow.common.core.domain.AjaxResult;
import com.bestow.common.enums.BusinessType;
import com.bestow.basic.domain.FndAtmAttachmentMulti;
import com.bestow.basic.service.IFndAtmAttachmentMultiService;
import com.bestow.common.utils.poi.ExcelUtil;
import com.bestow.common.core.page.TableDataInfo;

/**
 * 附件关联Controller
 * 
 * @author liliu
 * @date 2022-09-22
 */
@RestController
@RequestMapping("/basic/atmAttachmentMulti")
public class FndAtmAttachmentMultiController extends BaseController
{
    @Autowired
    private IFndAtmAttachmentMultiService fndAtmAttachmentMultiService;

    /**
     * 查询附件关联列表
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:list')")
    @GetMapping("/list")
    public TableDataInfo list(FndAtmAttachmentMulti fndAtmAttachmentMulti)
    {
        startPage();
        List<FndAtmAttachmentMulti> list = fndAtmAttachmentMultiService.selectFndAtmAttachmentMultiList(fndAtmAttachmentMulti);
        return getDataTable(list);
    }

    /**
     * 导出附件关联列表
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:export')")
    @Log(title = "附件关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FndAtmAttachmentMulti fndAtmAttachmentMulti)
    {
        List<FndAtmAttachmentMulti> list = fndAtmAttachmentMultiService.selectFndAtmAttachmentMultiList(fndAtmAttachmentMulti);
        ExcelUtil<FndAtmAttachmentMulti> util = new ExcelUtil<FndAtmAttachmentMulti>(FndAtmAttachmentMulti.class);
        util.exportExcel(response, list, "附件关联数据");
    }

    /**
     * 获取附件关联详细信息
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:query')")
    @GetMapping(value = "/{recordId}")
    public AjaxResult getInfo(@PathVariable("recordId") Long recordId)
    {
        return AjaxResult.success(fndAtmAttachmentMultiService.selectFndAtmAttachmentMultiByRecordId(recordId));
    }

    /**
     * 新增附件关联
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:add')")
    @Log(title = "附件关联", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FndAtmAttachmentMulti fndAtmAttachmentMulti)
    {
        return toAjax(fndAtmAttachmentMultiService.insertFndAtmAttachmentMulti(fndAtmAttachmentMulti));
    }

    /**
     * 修改附件关联
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:edit')")
    @Log(title = "附件关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FndAtmAttachmentMulti fndAtmAttachmentMulti)
    {
        return toAjax(fndAtmAttachmentMultiService.updateFndAtmAttachmentMulti(fndAtmAttachmentMulti));
    }

    /**
     * 删除附件关联
     */
    @PreAuthorize("@ss.hasPermi('basic:atmAttachmentMulti:remove')")
    @Log(title = "附件关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{recordIds}")
    public AjaxResult remove(@PathVariable Long[] recordIds)
    {
        return toAjax(fndAtmAttachmentMultiService.deleteFndAtmAttachmentMultiByRecordIds(recordIds));
    }
}
